If several replicas (or even all) had replication stuck, then the
timeout would happen for each server, one after another.
Change-Id: Id5431360b9cde7e5dc0115a1f41b9903003f47c4
}
public function waitForAll( $pos, $timeout = null ) {
}
public function waitForAll( $pos, $timeout = null ) {
+ $timeout = $timeout ?: $this->mWaitTimeout;
+
$oldPos = $this->mWaitForPos;
try {
$this->mWaitForPos = $pos;
$oldPos = $this->mWaitForPos;
try {
$this->mWaitForPos = $pos;
$ok = true;
for ( $i = 1; $i < $serverCount; $i++ ) {
if ( $this->mLoads[$i] > 0 ) {
$ok = true;
for ( $i = 1; $i < $serverCount; $i++ ) {
if ( $this->mLoads[$i] > 0 ) {
- $ok = $this->doWait( $i, true, $timeout ) && $ok;
+ $start = microtime( true );
+ $ok = $this->doWait( $i, true, max( 1, (int)$timeout ) ) && $ok;
+ $timeout -= ( microtime( true ) - $start );
+ if ( $timeout <= 0 ) {
+ break; // timeout reached
+ }